/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.WebIDE.ejb.sessions;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.WebIDE.ejb.entities.*;
import javax.ejb.Stateless;
import javax.ejb.Stateful;
import javax.ejb.SessionContext;

/**
 *
 * @author huy
 */
@Stateless
public class UserManagerBean implements UserManagerRemote, UserManagerLocal {

    @PersistenceContext(unitName = "WebIDE-ejbPU")
    private EntityManager em;

    public void persist(Object object) {
        em.persist(object);
    }

    public List findAllUsers() {
        List users = em.createNamedQuery("Users.findAll").getResultList();
        return users;
    }
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method" or "Web Service > Add Operation")

    public int count() {
        return ((Long) em.createNamedQuery("Users.count").getSingleResult()).intValue();
    }
}
